import Vue from 'vue'
import VueRouter from 'vue-router'
Vue.use(VueRouter)
// /main  3段式 /main/phone   /main/music  /main/browser /main/camera
//
// /login 登录
const routes=[
  {
    name: 'index',
    path:'/',
    component: require('./views/index'),
    //children:[
    //  [
    //    //{ path: '', component: require('./views/vux-page') },
    //    //{ path: 'profile', component: UserProfile },
    //    //{ path: 'posts', component: UserPosts }
    //  ]
    //]
  },
  {
    name: 'vux-page',
    path:'/vux-page',
    component: require('./views/vux-page')
  },
  {
    name: '404',
    path:'*',
    component: require('./views/page')
  },
  // '/tab/:tab/page/:page': {
  //   name: 'tab',
  //   component: require('./views/page'),
  // },
  //
  // '/post/:id': {
  //   name: 'post',
  //   component: require('./views/post'),
  // },
  //
  // '/login': {
  //   name: 'login',
  //   component: require('./views/login'),
  // },
  //
  // '/user/:name': {
  //   name: 'user',
  //   component: require('./views/user'),
  // },
  //
  // '/create': {
  //   name: 'create',
  //   component: require('./views/create'),
  //   auth: true,
  // },
  //
  // '/messages': {
  //   name: 'messages',
  //   component: require('./views/message'),
  //   auth: true,
  // },

];
const router = new VueRouter({
  routes:routes
});
router.beforeEach((to, from, next) => {
  // const scrollTop = document.body.scrollTop
  // const path = store.state.route.path
  // if (path) {
  //   if (scrollTop) ls.set(path, scrollTop)
  //   if (ls.get(path) && !scrollTop) ls.remove(path)
  // }
  // store.dispatch('gProgress', 0)
  next()
})
export default router;
